# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
# 题目：
# 有一个列表 list_num = [1、2、3、4]，里面的数字能组成多少个互不相同且无重复数字的三位数？
# 各是多少？
# 使用while循环 + 迭代器完成

# while循环
num_list = [1, 2, 3, 4]
count = 0                             # 计数
list_one = num_list.__iter__()        # 获取迭代器
number_one = 1
while number_one <= 4:
    data_one = list_one.__next__()      # 从迭代器中取值
    number_two = 1
    list_two = num_list.__iter__()
    # print(data_one)                  # 测试
    while number_two <= 4:
        data_two = list_two.__next__()
        number_three = 1
        list_three = num_list.__iter__()
        # print(data_one, data_two)    # 测试
        while number_three <= 4:
            data_three = list_three.__next__()
            # print(data_one, data_two, data_three)    # 测试
            if (data_one != data_two) and (data_one != data_three) and (data_two != data_three):
                print("%d%d%d" % (data_one, data_two, data_three), end=" ")
                count += 1
            number_three += 1
        number_two += 1
    number_one += 1

    print()
print(f"一共有：{count}个")


# for循环完成
# list_num = [1, 2, 3, 4]
# count = 0    # 计数
# for one in range(1, len(list_num)+1):          # 遍历列表的到百位
#     # print(one)                        # 测试打印结果
#     for two in range(1, len(list_num)+1):      # 遍历列表得到十位
#         # print(one, two)               # 测试打印结果
#         for three in range(1, len(list_num)+1):  # 遍历列表得到个位
#             # print(one, two, three)    # 测试打印结果
#             if (one != two) and (one != three) and (two != three):    # 判断无重复数字
#                 count += 1
#                 print("%d%d%d" % (one, two, three), end=" ")
#     print()
# print(f"一共有{count}个")
